


//
//  BAAlbumItem.m
//  BabyAlbum
//
//  Created by master on 17/2/23.
//  Copyright © 2017年 master. All rights reserved.
//

#import "BAAlbumItem.h"
#import "BAResource.h"
@implementation BAAlbumItem
- (BAAlbumItem *)autoFetch {
    return self;
}
- (BOOL)isSetted {
    return NO;
}

- (UIImage *)coverImage {
    return nil;
}

@end

@implementation BAAlbumVideoItem

- (BAAlbumVideoItem *)autoFetch {
    self.video = [BAResource videoNamed:self.name];
    if(self.video == nil) {
        return nil;
    }
    return self;
}
+ (BAAlbumVideoItem *)itemWithVideoAsset:(AVURLAsset *)asset {
    BAAlbumVideoItem *item = [[BAAlbumVideoItem alloc] init];
    item.video = asset;
    return item;
}

- (instancetype)init {
    self = [super init];
    self.type = BAResourceTypeVideo;
    return self;
}

- (BOOL)isSetted {
    return self.video != nil;
}

- (UIImage *)coverImage {
    return [self.video getThumbnailImage];
}

@end

@implementation BAAlbumImageItem

- (BAAlbumImageItem *)autoFetch {
    self.image = [BAResource imageNamed:self.name];
    if(!self.image) {
        return nil;
    }
    return self;
}

+ (BAAlbumImageItem *)itemWithImage:(UIImage *)image {
    BAAlbumImageItem *item = [[BAAlbumImageItem alloc] init];
    item.image = image;
    return item;
}

- (BOOL)isSetted {
    return self.image != nil;
}


- (instancetype)init {
    self = [super init];
    self.type = BAResourceTypeImage;
    return self;
}
- (UIImage *)coverImage {
    return self.image;
}
@end
